<div class="row">  
   <div class="span3 bs-docs-sidebar ">
 	<*include file="<*$controller*>/location.tpl"*>
  </div> 
  <div class="span9">
    <*if $type=='student'*>  
       <form action="/<*$controller*>/<*$action*>/type/<*$type*>" method="get" class="form-horizontal" name="form1"> 
		<input  type="text" name="text"  placeholder="输入名称、手机号、登陆账号" value="<*$keywolrd*>" /> 
        <input type="submit" class="btn btn-success"  value="查询"  >
        <input type="button" class="btn btn-success" value="清空查询" onclick="window.location='/<*$controller*>/<*$action*>/type/<*$type*>'" >  
       </form>  
       <*else*> 
      
        <form  name="form1"  method="get" class="form-horizontal" action="/<*$controller*>/<*$action*>/type/<*$type*>"> 
          机构:<select id="jigou" name="groups"  onchange="getSchool(this.value)"></select>
          校园:<select id="school" name="school"  onchange="getClass(this.value)"></select> 
          班级:<select id="class1" name="class" ></select>
          <input type="submit" class="btn btn-success"  value="查询"  >
          <input type="button" class="btn btn-success" value="清空查询" onclick="window.location='/<*$controller*>/<*$action*>'" >
       </form> 
     <*/if*>  
    
  <*if $result|@count neq 0*>  
    <*if $type=='student'*>
       <table cellpadding="0" cellspacing="0" class="table">
             <tr> 
                <th class="span2">登陆账号</th> 
                <th class="span2">家长名称</th>
                <th class="span2">电话</th>
                <th class="span2">token码</th> 
                <th>&nbsp;</th>
            </tr>
         
        <*foreach from=$result item=a key =key name=foo*>
            <tr> 
                <td><*$a.username*></td> 
                <td><*$a.realname*></td>
                <td><*$a.mobile*></td>
                <td><*$a.token*></td>  
                <td>&nbsp;</td>
            </tr>
            <*/foreach*> 
     <*else*>   
     <!--家长的信息 -->
       <table cellpadding="0" cellspacing="0" class="table">
                <tr> 
                <th class="span4">所属机构</th> 
                <th class="span4">所属校园</th> 
                <th class="span2">班级名称</th>
                <th class="span2">班级登陆账号</th> 
                <th class="span3">token码</th> 
                <th>&nbsp;</th>
            </tr> 
        <*foreach from=$result item=a key =key name=foo*>
            <tr> 
                <td><*$a.groupname*></td>
                <td><*$a.schoolname*></td>
                <td><*$a.classname*></td> 
                <td><*$a.username*></td> 
                <td><*$a.token*></td> 
                <td>&nbsp;</td>
            </tr>
            <*/foreach*>  
         <*/if*> 
        <tr>
        	<td colspan="8"><*$page*></td>
            <td>&nbsp;</td>
        </tr>
       <*else*>    
          <tr>
        	<td colspan="8">暂时没有token码哦！</td>
            <td>&nbsp;</td>
        </tr> 
       <*/if*> 
        </table>
     
	  </div>  
    </div>
</div>
 
<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript">
   window.onload=function(){
	 jigou();  
	if('<*$groups*>' != ''){
		getSchool('<*$groups*>');
	}
	if('<*$school*>' != ''){
		getClass('<*$school*>');
	} 
 } 
 
function jigou()
{   
   
	var url     = '/<*$controller*>/groups/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '';
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_groups});

} 
function showResponse_groups(originalRequest)
    {     
		 document.all.form1.groups.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		 
		 if('<*$groups*>' != ''){
			 jsSelectIsExitItem(document.all.form1.groups,'<*$groups*>');
	        } 
    }  

function getSchool(a)
{  
	var url  = '/<*$controller*>/schoollist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_school});

} 
function showResponse_school(originalRequest)
{
	{    
		 document.all.form1.school.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		 if('<*$school*>' != ''){
				jsSelectIsExitItem(document.all.form1.school,'<*$school*>');
			}
	 } 
} 



function getClass(a)
{  
     
	var url  = '/<*$controller*>/classlist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_class});

} 
function showResponse_class(originalRequest)
{
	{    //alert(originalRequest.responseText);  
		 document.all.form1.class.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		 if('<*$classid*>' != ''){
				jsSelectIsExitItem(document.all.form1.class,'<*$classid*>');
			}
	 } 
} 
 

function deleteit(id,type)
{
  if(confirm("删除将不能恢复")){
   window.location='/<*$controller*>/delete/id/'+id+'/type/'+type;
  }
}

function haveparents(id,page)
{ 
   window.location='/<*$controller*>/haveparents/id/'+id+'/page/'+page;
}

function editit(id,pageNum)
{
	 
 	window.location='/<*$controller*>/editparents/id/'+id+'/pageNum/'+pageNum;
}
function opcourse(id)
{  
	//alert(reason[14]);
	var url  = '/<*$controller*>/lock/';

	var pars = '&id=' + id;
	//var pars = '&id=' + id +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason; 
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_course});

}

function showResponse_course(originalRequest)
{
	//alert(originalRequest.responseText);
	if(originalRequest.responseText =='-1'){
		alert('参数错误');
		return false;
	}else if(originalRequest.responseText =='-2'){
		alert('请输入原始密码！');
		return false;
	}else if(originalRequest.responseText =='-3'){
		alert('请输入新密码！');
		return false;
	}else if(originalRequest.responseText =='-4'){
		alert('2次密码不一致！');
		return false;
	}else if(originalRequest.responseText =='-5'){
		alert('新密码和旧密码不能一致！');
		return false;
	}else if(originalRequest.responseText =='-6'){
		alert('原始密码错误！');
		return false;
	}else if (originalRequest.responseText =='1')
	{
		alert('修改成功，请重新登录！');
		parent.location.reload();
	} 
} 
function jsSelectIsExitItem(objSelect, objItemValue) {
	//alert(objSelect.options.length);
    for (var i = 0; i < objSelect.options.length; i++) {
        if (objSelect.options[i].value == objItemValue) { 
			objSelect.options[i].selected=true;
        	 break;
        }
    }
    return 1;
} 
</script>
